package servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


/**
 * Servlet implementation class ChoiceServlet
 */
@WebServlet("/ChoiceServlet")
public class ChoiceServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#HttpServlet()
	 */
	public ChoiceServlet() {
		super();
		// TODO Auto-generated constructor stub
	}

	public void init() {

	}

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		HttpSession session = request.getSession(true);

		PrintWriter out = response.getWriter();

		String nume =  request.getParameter("studIndex");

		session.setAttribute("studNume", nume);

		out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 "
				+ "Transitional//EN\">");

		out.println("<html>");
		out.println("<head>");
		out.println("<title>" + "Main page!" + "</title>");
		out.println("</head>");
		out.println("<body bgcolor=\"#F3FBFE\">");
		out.println("<br>");
		out.println("Alege o operatie pentru :" + nume);
		out.println("<form method=\"GET\" action=\"/ServletTest/DispatcherServlet\"> ");

		out.println("<br> 1.Notele pentru student la o materie");
		out.println("<input type=\"submit\" name=\"note\" value=\"Choose\">");

		out.println("<br> 2.Media notelor mai mari decat 5");
		out.println("<input type=\"submit\" name=\"media\" value=\"Choose\">");

		out.println("<br> 3.Report pe o anumita data");
		out.println("<input type=\"submit\" name=\"raport\" value=\"Choose\">");

		out.println("<br><br><input type=\"submit\" name=\"main\" value=\"Main\"></form>");

		out.println("</body>");
		out.println("</html>");

	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		doGet(request, response);
	}

}
